        package DAL;

        import java.util.*;
        
        import DBUtil.SQLUtil;
        
        public class Math {

		//获取比赛表信息列表
		public List<Object> getEntity()
		{
			String sqlCmd="select *from Math";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
            
               //获取分页后比赛表信息列表
		public List<Object> getEntity(int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from V_Math limit "+size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
		}
                
               //根据查询条件sqlWhere获取分页后比赛表信息列表
		public List<Object> getEntityByWhere(String sqlWhere,int page)
		{
			int size=(page-1)*15;
			String sqlCmd="select *from V_Math where "+sqlWhere+" limit "+ size+",15";
			return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //删除比赛表信息
        public int deleteEntity(String MathId)
        {
            String sqlCmd="delete from Math where MathId='"+MathId+"'";
            return DBUtil.SQLUtil.executeNonQuery(sqlCmd, null);//执行非查询操作executeNonQuery
        }
        
        //根据比赛表编号获取比赛表信息
        public List<Object> getEntityById(String MathId)
        {
            String sqlCmd="select *From Math where MathId='"+MathId+"'";
            return DBUtil.SQLUtil.executeQuery(sqlCmd, null);//执行查询操作executeQuery
        }
        
        //更新比赛表信息
        public int updateEntity(String MathId,String MathName,String MathStartime,String MathLocation,String JudgeId,String MathIsDel,String MathTag)
        {
            String sqlCmd="Update Math set MathName='" + MathName + "',MathStartime='" + MathStartime + "',MathLocation='" + MathLocation + "',JudgeId='" + JudgeId + "',MathIsDel='" + MathIsDel + "',MathTag='" + MathTag + "' where MathId='"+MathId+"'";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //插入比赛表信息
        public int insertEntity(String MathId,String MathName,String MathStartime,String MathLocation,String JudgeId,String MathIsDel,String MathTag)
        {
            String sqlCmd="Insert into Math values('" + MathId + "','" + MathName + "','" + MathStartime + "','" + MathLocation + "','" + JudgeId + "','" + MathIsDel + "','"+MathTag+"')";
            return SQLUtil.executeNonQuery(sqlCmd, null);
        }
        
        //检查插入主键是否重复
        public boolean checkExist(String MathId)
        {
            String sqlCmd="select count(*) from Math where MathId='"+MathId+"'";
            if(1==Integer.parseInt(SQLUtil.excuteScalar(sqlCmd, null).toString()) )
            {
                return true;
            }
            return false;
        }

		//获取分页总数
		public Object getPageCount()
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM V_Math ";
			return SQLUtil.excuteScalar(sqlCmd, null);
		}

		//根据查询条件获取分页总数
		public Object getPageCountByWhere(String sqlWhere)
		{
			String sqlCmd="SELECT CEIL( COUNT(*)/15.0) FROM V_Math where "+sqlWhere;
			return SQLUtil.excuteScalar(sqlCmd, null);
		}
            
        }
